package com.muyi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyi.pojo.dto.PaperDTO;
import com.muyi.pojo.dto.PaperSelectDTO;
import com.muyi.pojo.entity.Paper;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

/**
* @author VRMMO
* @description 针对表【paper】的数据库操作Mapper
* @createDate 2025-06-11 15:04:41
* @Entity com.muyi.pojo.entity.Paper
*/
@Mapper
public interface PaperMapper extends BaseMapper<Paper> {
    /**
     * 查询全部文章
     * @return
     */
    List<PaperSelectDTO> list(@Param("paper_title")String paper_title, @Param("begin")LocalDate begin, @Param("end") LocalDate end,
                                  @Param("tag_name")String tag_name, @Param("category_name")String category_name);


    /**
     * 根据ID删除文章
     * @param paper_id
     */
    @Delete("delete from paper where paper_id = #{paper_id}")
    void deleteById(Integer paper_id);

    /**
     * 新增文章
     *
     * @param paper
     * @return
     */
    int insertAll(Paper paper);


    /**
     * 更新文章
     * @param paper
     */
    void update(Paper paper);

    @Select("select * from paper where paper_id = #{paper_id}")
    Paper getByPaperId(Integer paper_id);

    /**
     * 更新文章的浏览数
     * @param paper_id
     */
    @Update("update paper set view_count = view_count + 1 where paper_id = #{paper_id}")
    void updateViewCount(Integer paper_id);
}




